-
Notifications
You must be signed in to change notification settings - Fork 230
Recursive type substitution in TypeLibrary.MakeGenericType #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
837ed27 to
db79fbb
Compare
…c into make-generic-type-fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes recursive generic type constraint validation in TypeLibrary.MakeGenericType by implementing proper type parameter substitution when checking constraints. Previously, the method failed to validate constraints correctly when generic parameters appeared recursively within their own constraint definitions (e.g., where T : IConstraintBreaker2<T, T, T>).
Changes:
- Added type parameter substitution logic to replace generic parameters with their concrete type arguments when validating constraints
- Added test coverage for recursive generic constraint validation with both valid and invalid type arguments
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| engine/Sandbox.Reflection/TypeLibrary/TypeDescription.cs | Implements recursive type substitution in MakeGenericType to properly validate generic constraints |
| engine/Sandbox.Test.Unit/Reflection/TypeLibraryTest.cs | Adds test cases and supporting types to verify recursive generic constraint validation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Manonox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fairly good explanation from le bot
Changes - meh
Fixes: Facepunch/sbox-issues#9813
(Look there for details)
There's also a new test: